<template>
  <Dialog title="处方单详情" class="two-columns" :visible="visible" :reveal="false" @close="close">
    <!-- 病历详情 -->
    <UserInfo :info-id="customerId" />
    <el-table
      :data="detailsData.prescriptionListDetailsDtoList"
      style="width: 100%"
    >
      <el-table-column
        prop="medicinesName"
        label="名称"
      />
      <el-table-column
        prop="medicinesSpec"
        label="规格"
      />
      <el-table-column
        prop="medicinesUnit"
        label="单位"
      />
      <el-table-column
        prop="usageMethod"
        label="用法"
      />
      <el-table-column
        prop="frequency"
        label="频率"
      />
      <el-table-column
        prop="quantity"
        label="数量"
      />
      <el-table-column
        prop="price"
        label="单价"
      />
      <el-table-column
        prop="oneAllPrice"
        label="总价"
      />
    </el-table>
    <el-row>
      <el-col class="right">
        合计：
        <span>￥{{ allPrice }}</span>
      </el-col>
    </el-row>
    <el-row class="font-size">
      <el-col>
        付款方式：{{ detailsData.paymentMethod }} <span style="margin-left:18px">状态：{{ detailsData.status }}</span>
      </el-col>
      <!-- <el-col>
        状态：{{ detailsData.status }}
      </el-col> -->
    </el-row>
    <el-row class="dotted font-size">
      <el-col>
        医嘱：{{ detailsData.medicalAdvice?detailsData.medicalAdvice:'无' }}
      </el-col>
    </el-row>
    <el-row type="flex">
      <span class="margin-right">处方单号：{{ detailsData.prescriptionNo }}</span>
      <span class="margin-right">科室：{{ detailsData.deptName }}</span>
      <span class="margin-right">开单人：{{ detailsData.drawerName }}</span>
      <span class="margin-right">开单时间：{{ detailsData.createdTime }}</span>
      <!-- <el-col>
        处方单号：{{ detailsData.prescriptionNo }}
      </el-col>
      <el-col>
        科室/部门：{{ detailsData.deptName }}
      </el-col>
      <el-col>
        开单人：{{ detailsData.drawerName }}
      </el-col>
      <el-col>
        审核人：{{ detailsData.reviewerName }}
      </el-col> -->
    </el-row>
    <div class="all-margin-bottom" />
  </Dialog>
</template>
<script>
import Dialog from '@/components/Dialog';
import UserInfo from '@/components/UserInformation';
export default {
  components: {
    Dialog,
    UserInfo,
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    medicalDetailsId: {
      type: [Number, String],
      default: '',
    },
    customerId: {
      type: [Number, String],
      default: 0,
    },
  },
  data() {
    return {
      detailsData: {},
      allPrice: 0,
    };
  },
  watch: {
    medicalDetailsId: {
      handler(newId) {
        this.getDetails(newId);
      },
    },
  },
  mounted() {
    this.getDetails(this.medicalDetailsId);
  },
  methods: {
    close() {
      this.$emit('seeDetails', false);
    },
    getDetails(id) { // 请求列表的数据
      if (!id) return false;
      this.allPrice = 0;
      this.$api['department/order/prescriptionlistid']({ id }).then(res => {
        if (res.code !== 200) return this.$message.error("查询处方详情失败");
        res.data.prescriptionListDetailsDtoList.forEach(item => {
          // this.$set(item, 'oneAllPrice', Number(item.price) * Number(item.quantity) / 100 * 100);
          this.$set(item, 'oneAllPrice', Math.floor((Number(item.price) * Number(item.quantity) * 100) / 100));
          this.allPrice += item.oneAllPrice;
        });
        this.detailsData = res.data;
      });
    },
  },
};
</script>
<style lang="scss" scoped>
  .divs{
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    >span{
      display: inline-block;
      width: 10px;
      height: 30px;
      background: #0099ff;
      margin-right: 10px;
    }
  }
  .right{
    text-align: right;
    margin: 15px 0;
    span{
      color: #ff6600;
    }
  }
  .dotted{
    padding:10px 0 15px 0;
    border-bottom:1px solid #000;
    margin-bottom: 15px;
  }
  .el-col{
    line-height: 30px;
  }
  .margin-right{
    margin-right: 50px;
    font-size: 12px;
  }
  .font-size{
    font-size: 12px;
  }
</style>
